termux-setup-storage
# termux-change-repo
mkdir -p $PREFIX/etc/termux/

cat <<'EOF' > "$PREFIX/etc/termux/chosen_mirrors"
# This file is sourced by pkg
# Mirror by Tsinghua University TUNA Association
WEIGHT=1
MAIN="https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-main"
ROOT="https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-root"
X11="https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-x11"

EOF


# chmod 777 "$PREFIX/etc/termux/chosen_mirrors"}
mkdir -p $PREFIX/etc/apt/

cat <<'EOF' > $PREFIX/etc/apt/sources.list
# The termux repository mirror
deb https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-main stable main

EOF


## Cargo crates-io 稀疏索引镜像

cat <<'EOF' > $HOME/.cargo/config.toml
[source.crates-io]
replace-with = 'mirror'

[source.mirror]
registry = "sparse+https://mirrors.tuna.tsinghua.edu.cn/crates.io-index/"

EOF

pkg i root-repo x11-repo -y
pkg upg -y
pkg i termux-api termux-services expect -y
pkg i build-essential llvm-mingw-w64 git git-lfs rust python -y

# 使用 expect 自动输入密码
PASSWORD="teo"
$PREFIX/bin/expect  <<EOF
spawn  passwd
expect "New password:"
send "$PASSWORD\r"
expect "Retype new password:"
send "$PASSWORD\r"
expect eof

EOF


pkg i helix zellij tree which fastfetch uv bash-completion file 7zip calc -y

cat <<'EOF' > ~/.bashrc
if [ -e $PREFIX/bin/fastfetch ] ; then
	fastfetch
fi
if [ -e $PREFIX/share/bash-completion/bash_completion ] ; then
	. $PREFIX/share/bash-completion/bash_completion
fi

## Alias
alias "cls=clear"
alias "ll=ls -lah"
alias "..=cd .."

##
sshd
sv-enable sshd

EOF


. ~/.bashrc 
pkg i wget aria2  -y
pkg i typst -y
pip config set --global global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
pkg i python-numpy matplotlib python-torch python-torchaudio python-torchvision python-scipy python-pyarrow -y
pkg i libhdf5 -y

pip install meson-python cython --no-build-isolation
pip install scikit-learn --no-build-isolation
pip install setuptools pkgconfig --no-build-isolation
pip install optree --no-build-isolation
pip install keras --no-build-isolation

if [ $1 -eq 1 ] ; then
pkg i tur-repo -y
pkg i gcc-default-14 -y
pkg i python-pandas python-polars -y
pip install maturin 
pip install seaborn --no-build-isolation
fi 
